<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\admin\controller\Common;
use think\Request;
use think\facade\View;

class News extends Common
{
	public function __construct(){
		parent::__construct();
		$this->model = new \app\admin\model\News;
		View::assign('model',$this->model);
		View::assign('title',"文章管理");
		$this->validate = new \app\admin\validate\News;

		/**
		 * 表结构
		 */
		$this->tables = config('tables.news');
		View::assign('tables',$this->tables);

		/**
		 * 菜单列表
		 */
		$classsmodel = new \app\admin\model\Classs;
		$classslists = $classsmodel->level();
		$classs = [];
		get_level($classslists,$classs,'classs_id',0,'id');
		View::assign('classs',$classs);

		$this->auth_rule = [
			[
				'name'  => "news/index",
				'title' => "文章-列表",
				'class' => "news",
			],
			[
				'name'  => "news/create",
				'title' => "文章-添加",
				'class' => "news",
			],
			[
				'name'  => "news/read",
				'title' => "文章-阅读",
				'class' => "news",
			],
			[
				'name'  => "news/edit",
				'title' => "文章-修改",
				'class' => "news",
			],
			[
				'name'  => "news/delete",
				'title' => "文章-删除",
				'class' => "news",
			],
			[
				'name'  => "news/copy",
				'title' => "文章-复制",
				'class' => "news",
			],
		];
	}
	
	/**
	 * 排序
	 */
	protected function order(){
		return "create_time desc,id asc";
	}
}
